package com.key.service.impl;

import com.key.entity.Employee;
import com.key.mapper.EmployeeMapper;
import com.key.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author：朕
 * @Package：com.key.service.impl
 * @Project：ams_system
 * @name：EmployeeServiceImpl
 * @Date：2023/2/22 12:34
 * @Filename：EmployeeServiceImpl
 */
@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;

    /**
     * 显示员工信息
     * @return
     */
    @Override
    public List<Employee> findEmployee() {
        List<Employee> employees = employeeMapper.findEmployee();
        return employees;
    }

    /**
     * 添加员工信息
     * @param employee
     * @return
     */
    @Override
    public boolean addEmployee(Employee employee) {
        int e = employeeMapper.addEmployee(employee);
        if(e>0){
            return true;
        }else{
            return false;
        }
    }

    /**
     * 删除员工信息
     * @return
     */
    @Override
    public boolean deleteEmployee(int employeeId) {
        int e = employeeMapper.deleteEmployee(employeeId);
        if(e>0){
            return true;
        }else{
            return false;
        }
    }

    /**
     * 根据员工Id查询员工信息
     * @return
     */
    @Override
    public List<Employee> findEmployeeById(int employeeId) {
        List<Employee> employees = employeeMapper.findEmployeeById(employeeId);
        return employees;
    }

    /**
     * 修改员工信息
     * @param employee
     * @return
     */
    @Override
    public boolean updateEmployee(Employee employee) {
        int e = employeeMapper.updateEmployee(employee);
        if(e>0){
            return true;
        }else{
            return false;
        }
    }

}
